#include <iostream>
#include <future>
#include <unistd.h>
int Add(int num1, int num2)
{
    std::cout << num1 + num2 << std::endl;
    return num1 + num2;
}
int main()
{
    std::cout << "-----1-----" << std::endl;
    std::future<int> future = std::async(std::launch::deferred, Add, 1, 2); //等到get的时候再执行
    std::future<int> future = std::async(std::launch::async, Add, 1, 2); //创建线程，异步执行
    sleep(1);
    std::cout << "-----2-----" << std::endl;
    std::cout << future.get() << std::endl;
    std::cout << "-----3-----" << std::endl;

    return 0;
}